package cn.cxion.chat.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.ToastUtils;
import com.makeramen.roundedimageview.RoundedImageView;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.cxion.chat.R;
import cn.cxion.chat.app.Fragment.WorkFragment;
import cn.cxion.chat.app.activity.ConstantActivity;
import cn.cxion.chat.app.bean.OnHandInfo;
import cn.cxion.chat.app.constant.Constant;
import cn.cxion.chat.app.view.OnHandItemView;

public class WorkAdapter extends RecyclerView.Adapter<WorkAdapter.MyViewHolder>{


    private Context context;
    private List<OnHandInfo> list;

    public WorkAdapter(Context context){
        this.context=context;
    }

    public List<OnHandInfo> getList() {
        return list;
    }

    public void setList(List<OnHandInfo> list) {
        this.list = list;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return  new MyViewHolder(View.inflate(context, R.layout.itemview_onhand, null));
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        holder.tv1.setText(list.get(position).getT1());
        holder.tv2.setText(list.get(position).getT2());
        holder.tv3.setText(list.get(position).getT3());
//        holder.tvTime.setText(list.get(position).getTime());
//        if (list.get(position).getType()==1){
//            holder.imgState.setImageResource(R.drawable.vector_onhand_itemtype1);
//        }else if(list.get(position).getType()==2){
//            holder.imgState.setImageResource(R.drawable.vector_onhand_itemtype2);
//        }else{
//            holder.imgState.setImageResource(R.drawable.vector_onhand_itemtype3);
//        }
        holder.llHold.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ConstantActivity.show(context, Constant.CHECKCONTRACT);
            }
        });
    }

    @Override
    public int getItemCount() {
        return list==null?0:list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{
        @Bind(R.id.img_photo)
        RoundedImageView imgPhoto;
        @Bind(R.id.img_state)
        ImageView imgState;
        @Bind(R.id.tv1)
        TextView tv1;
        @Bind(R.id.tv2)
        TextView tv2;
        @Bind(R.id.tv3)
        TextView tv3;
        @Bind(R.id.tv_time)
        TextView tvTime;
        @Bind(R.id.ll_hold)
        LinearLayout llHold;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
